bitkeeper revision 1.1108.36.1 (4108f279nPgkLZARXvnqXNBEsFkj4Q)
authorgm281@boulderdash.cl.cam.ac.uk <gm281@boulderdash.cl.cam.ac.uk>
Thu, 29 Jul 2004 12:50:01 +0000 (12:50 +0000)
committergm281@boulderdash.cl.cam.ac.uk <gm281@boulderdash.cl.cam.ac.uk>
Thu, 29 Jul 2004 12:50:01 +0000 (12:50 +0000)
The runqueue management functions removed from sched-if.h and put into schedulers

xen/common/sched_bvt.c
xen/common/sched_fair_bvt.c
xen/common/sched_rrobin.c
xen/include/xen/sched-if.h

index c03f2a78d376eaa9266dcbb68253b66ddc511e0a..41efe9fd1c5127eb608ec6a71ca7dcabb253cece 100644 (file)
@@ -53,8 +53,8 @@ struct bvt_cpu_info
 
 #define BVT_INFO(p)   ((struct bvt_dom_info *)(p)->sched_priv)
 #define CPU_INFO(cpu) ((struct bvt_cpu_info *)(schedule_data[cpu]).sched_priv)
-#define RUNLIST(p)    &(BVT_INFO(p)->run_list)
-#define RUNQUEUE(cpu) &(CPU_INFO(cpu)->runqueue)
+#define RUNLIST(p)    ((struct list_head *)&(BVT_INFO(p)->run_list))
+#define RUNQUEUE(cpu) ((struct list_head *)&(CPU_INFO(cpu)->runqueue))
 #define CPU_SVT(cpu)  (CPU_INFO(cpu)->svt)
 
 #define MCU            (s32)MICROSECS(100)    /* Minimum unit */
@@ -65,6 +65,32 @@ static s32 ctx_allow = (s32)MILLISECS(5);     /* context switch allowance */
 /* SLAB cache for struct bvt_dom_info objects */
 static xmem_cache_t *dom_info_cache;
 
+/*
+ * Wrappers for run-queue management. Must be called with the run_lock
+ * held.
+ */
+static inline void __add_to_runqueue_head(struct domain *d)
+{
+    list_add(RUNLIST(d), RUNQUEUE(d->processor));
+}
+
+static inline void __add_to_runqueue_tail(struct domain *d)
+{
+    list_add_tail(RUNLIST(d), RUNQUEUE(d->processor));
+}
+
+static inline void __del_from_runqueue(struct domain *d)
+{
+    struct list_head *runlist = RUNLIST(d);
+    list_del(runlist);
+    runlist->next = NULL;
+}
+
+static inline int __task_on_runqueue(struct domain *d)
+{
+    return (RUNLIST(d))->next != NULL;
+}
+
 /*
  * Calculate the effective virtual time for a domain. Take into account 
  * warping limits
@@ -152,8 +178,8 @@ int bvt_init_idle_task(struct domain *p)
     spin_lock_irqsave(&CPU_INFO(p->processor)->run_lock, flags);
     
     set_bit(DF_RUNNING, &p->flags);
-    if ( !__task_on_runqueue(RUNLIST(p)) )
-        __add_to_runqueue_head(RUNLIST(p), RUNQUEUE(p->processor));
+    if ( !__task_on_runqueue(p) )
+        __add_to_runqueue_head(p);
         
     spin_unlock_irqrestore(&CPU_INFO(p->processor)->run_lock, flags);
 
@@ -172,13 +198,13 @@ void bvt_wake(struct domain *d)
     spin_lock_irqsave(&CPU_INFO(cpu)->run_lock, flags);
     
     /* If on the runqueue already then someone has done the wakeup work. */
-    if ( unlikely(__task_on_runqueue(RUNLIST(d))) )
+    if ( unlikely(__task_on_runqueue(d)) )
     {
         spin_unlock_irqrestore(&CPU_INFO(cpu)->run_lock, flags);
         return;
     }
 
-    __add_to_runqueue_head(RUNLIST(d), RUNQUEUE(d->processor));
+    __add_to_runqueue_head(d);
 
     now = NOW();
 
@@ -222,8 +248,8 @@ static void bvt_sleep(struct domain *d)
         spin_lock_irqsave(&CPU_INFO(d->processor)->run_lock, flags);
         
         
-        if ( __task_on_runqueue(RUNLIST(d)) )
-            __del_from_runqueue(RUNLIST(d));
+        if ( __task_on_runqueue(d) )
+            __del_from_runqueue(d);
 
         spin_unlock_irqrestore(&CPU_INFO(d->processor)->run_lock, flags);    
     }
@@ -347,7 +373,7 @@ static task_slice_t bvt_do_schedule(s_time_t now)
     ASSERT(prev_inf != NULL);
     spin_lock_irqsave(&CPU_INFO(cpu)->run_lock, flags);
 
-    ASSERT(__task_on_runqueue(RUNLIST(prev)));
+    ASSERT(__task_on_runqueue(prev));
 
     if ( likely(!is_idle_task(prev)) ) 
     {
@@ -358,10 +384,10 @@ static task_slice_t bvt_do_schedule(s_time_t now)
         
         __calc_evt(prev_inf);
         
-        __del_from_runqueue(RUNLIST(prev));
+        __del_from_runqueue(prev);
         
         if ( domain_runnable(prev) )
-            __add_to_runqueue_tail(RUNLIST(prev), RUNQUEUE(cpu));
+            __add_to_runqueue_tail(prev);
     }
 
  
index 8659ab1daea502e4c2e62d3d0760d06e99e64794..4ecef6183e775c1119966a125df7be6fb3cf0352 100644 (file)
@@ -62,8 +62,8 @@ struct fbvt_cpu_info
 
 #define FBVT_INFO(p)  ((struct fbvt_dom_info *)(p)->sched_priv)
 #define CPU_INFO(cpu) ((struct fbvt_cpu_info *)(schedule_data[cpu]).sched_priv)
-#define RUNLIST(p)    (struct list_head *)(&(FBVT_INFO(p)->run_list))
-#define RUNQUEUE(cpu) (struct list_head *)&(CPU_INFO(cpu)->runqueue)
+#define RUNLIST(p)    ((struct list_head *)&(FBVT_INFO(p)->run_list))
+#define RUNQUEUE(cpu) ((struct list_head *)&(CPU_INFO(cpu)->runqueue))
 #define CPU_SVT(cpu)  (CPU_INFO(cpu)->svt)
 #define LAST_VTB(cpu) (CPU_INFO(cpu)->vtb)
 #define R_TIME(cpu)   (CPU_INFO(cpu)->r_time) 
@@ -77,6 +77,33 @@ static s32 max_vtb   = (s32)MILLISECS(5);
 /* SLAB cache for struct fbvt_dom_info objects */
 static xmem_cache_t *dom_info_cache;
 
+
+/*
+ * Wrappers for run-queue management. Must be called with the run_lock
+ * held.
+ */
+static inline void __add_to_runqueue_head(struct domain *d)
+{
+    list_add(RUNLIST(d), RUNQUEUE(d->processor));
+}
+
+static inline void __add_to_runqueue_tail(struct domain *d)
+{
+    list_add_tail(RUNLIST(d), RUNQUEUE(d->processor));
+}
+
+static inline void __del_from_runqueue(struct domain *d)
+{
+    struct list_head *runlist = RUNLIST(d);
+    list_del(runlist);
+    runlist->next = NULL;
+}
+
+static inline int __task_on_runqueue(struct domain *d)
+{
+    return (RUNLIST(d))->next != NULL;
+}
+
 /*
  * Calculate the effective virtual time for a domain. Take into account 
  * warping limits
@@ -163,8 +190,8 @@ int fbvt_init_idle_task(struct domain *p)
     fbvt_add_task(p);
     spin_lock_irqsave(&CPU_INFO(p->processor)->run_lock, flags);
     set_bit(DF_RUNNING, &p->flags);
-    if ( !__task_on_runqueue(RUNLIST(p)) )
-    __add_to_runqueue_head(RUNLIST(p), RUNQUEUE(p->processor));
+    if ( !__task_on_runqueue(p) )
+    __add_to_runqueue_head(p);
     spin_unlock_irqrestore(&CPU_INFO(p->processor)->run_lock, flags);
 
     return 0;
@@ -183,13 +210,13 @@ static void fbvt_wake(struct domain *d)
     spin_lock_irqsave(&CPU_INFO(cpu)->run_lock, flags);
     
     /* If on the runqueue already then someone has done the wakeup work. */
-    if ( unlikely(__task_on_runqueue(RUNLIST(d))) )
+    if ( unlikely(__task_on_runqueue(d)) )
     {
         spin_unlock_irqrestore(&CPU_INFO(cpu)->run_lock, flags); 
         return;
     }    
     
-    __add_to_runqueue_head(RUNLIST(d), RUNQUEUE(cpu));
+    __add_to_runqueue_head(d);
  
     now = NOW();
 
@@ -270,8 +297,8 @@ static void fbvt_sleep(struct domain *d)
          /* The runqueue accesses must be protected */
         spin_lock_irqsave(&CPU_INFO(d->processor)->run_lock, flags);       
     
-        if ( __task_on_runqueue(RUNLIST(d)) )
-            __del_from_runqueue(RUNLIST(d));
+        if ( __task_on_runqueue(d) )
+            __del_from_runqueue(d);
 
         spin_unlock_irqrestore(&CPU_INFO(d->processor)->run_lock, flags);
     }
@@ -398,7 +425,7 @@ static task_slice_t fbvt_do_schedule(s_time_t now)
     
     spin_lock_irqsave(&CPU_INFO(cpu)->run_lock, flags);
 
-    ASSERT(__task_on_runqueue(RUNLIST(prev)));
+    ASSERT(__task_on_runqueue(prev));
 
     if ( likely(!is_idle_task(prev)) ) 
     {
@@ -428,10 +455,10 @@ static task_slice_t fbvt_do_schedule(s_time_t now)
         
         __calc_evt(prev_inf);
         
-        __del_from_runqueue(RUNLIST(prev));
+        __del_from_runqueue(prev);
         
         if ( domain_runnable(prev) )
-            __add_to_runqueue_tail(RUNLIST(prev), RUNQUEUE(cpu));
+            __add_to_runqueue_tail(prev);
     }
 
     /* We should at least have the idle task */
index b5ab6000e5430ae4777d9775a57d745f19eb4ac3..289816f0b63993115e1d40b247f43a223914ebea 100644 (file)
@@ -26,15 +26,38 @@ struct rrobin_dom_info
 static spinlock_t run_locks[NR_CPUS];
 
 #define RR_INFO(d)      ((struct rrobin_dom_info *)d->sched_priv)
-#define RUNLIST(d)      (struct list_head *)&(RR_INFO(d)->run_list)
+#define RUNLIST(d)      ((struct list_head *)&(RR_INFO(d)->run_list))
 #define RUNQUEUE(cpu)   RUNLIST(schedule_data[cpu].idle)
 
-// TODO remove following line
-static void rr_dump_cpu_state(int cpu);
-
 /* SLAB cache for struct rrobin_dom_info objects */
 static xmem_cache_t *dom_info_cache;
 
+/*
+ * Wrappers for run-queue management. Must be called with the run_lock
+ * held.
+ */
+static inline void __add_to_runqueue_head(struct domain *d)
+{
+    list_add(RUNLIST(d), RUNQUEUE(d->processor));
+}
+
+static inline void __add_to_runqueue_tail(struct domain *d)
+{
+    list_add_tail(RUNLIST(d), RUNQUEUE(d->processor));
+}
+
+static inline void __del_from_runqueue(struct domain *d)
+{
+    struct list_head *runlist = RUNLIST(d);
+    list_del(runlist);
+    runlist->next = NULL;
+}
+
+static inline int __task_on_runqueue(struct domain *d)
+{
+    return (RUNLIST(d))->next != NULL;
+}
+
 
 /* Ensures proper initialisation of the dom_info */
 static void cache_constructor(void *arg1, xmem_cache_t *arg2, unsigned long arg3)
@@ -102,8 +125,8 @@ static int rr_init_idle_task(struct domain *p)
 
     spin_lock_irqsave(&run_locks[p->processor], flags);
     set_bit(DF_RUNNING, &p->flags);
-    if ( !__task_on_runqueue(RUNLIST(p)) )
-         __add_to_runqueue_head(RUNLIST(p), RUNQUEUE(p->processor));
+    if ( !__task_on_runqueue(p) )
+         __add_to_runqueue_head(p);
     spin_unlock_irqrestore(&run_locks[p->processor], flags);
     return 0;
 }
@@ -122,15 +145,15 @@ static task_slice_t rr_do_schedule(s_time_t now)
     
     if(!is_idle_task(prev))
     {
-        __del_from_runqueue(RUNLIST(prev));
+        __del_from_runqueue(prev);
     
         if ( domain_runnable(prev) )
-            __add_to_runqueue_tail(RUNLIST(prev), RUNQUEUE(cpu));
+            __add_to_runqueue_tail(prev);
     }
     
     spin_unlock_irqrestore(&run_locks[cpu], flags);
     
-    ret.task = list_entry(  RUNQUEUE(cpu).next->next, 
+    ret.task = list_entry(  RUNQUEUE(cpu)->next, 
                             struct rrobin_dom_info, 
                             run_list)->domain;
     ret.time = rr_slice;
@@ -166,8 +189,8 @@ static void rr_sleep(struct domain *d)
     else
     {
         spin_lock_irqsave(&run_locks[d->processor], flags);
-        if ( __task_on_runqueue(RUNLIST(d)) )
-            __del_from_runqueue(RUNLIST(d));
+        if ( __task_on_runqueue(d) )
+            __del_from_runqueue(d);
         spin_unlock_irqrestore(&run_locks[d->processor], flags);
     }
 }
@@ -182,13 +205,13 @@ void rr_wake(struct domain *d)
     spin_lock_irqsave(&run_locks[cpu], flags);
     
     /* If on the runqueue already then someone has done the wakeup work. */
-    if ( unlikely(__task_on_runqueue(RUNLIST(d))))
+    if ( unlikely(__task_on_runqueue(d)))
     {
         spin_unlock_irqrestore(&run_locks[cpu], flags);
         return;
     }
 
-    __add_to_runqueue_head(RUNLIST(d), RUNQUEUE(cpu));
+    __add_to_runqueue_head(d);
     spin_unlock_irqrestore(&run_locks[cpu], flags);
 
     now = NOW();
index ad1448b75653a90417d40238ce30c46b6b8ba2fa..15f992614ae80c1f18c8bc05e3e9da5c725f458e 100644 (file)
@@ -56,28 +56,4 @@ struct scheduler
 /* per CPU scheduler information */
 extern schedule_data_t schedule_data[];
 
-/*
- * Wrappers for run-queue management. Must be called with the schedule_lock
- * held.
- */
-static inline void __add_to_runqueue_head(struct list_head *run_list, struct list_head *runqueue)
-{
-    list_add(run_list, runqueue);
-}
-
-static inline void __add_to_runqueue_tail(struct list_head *run_list, struct list_head *runqueue)
-{
-    list_add_tail(run_list, runqueue);
-}
-
-static inline void __del_from_runqueue(struct list_head *run_list)
-{
-    list_del(run_list);
-    run_list->next = NULL;
-}
-
-static inline int __task_on_runqueue(struct list_head *run_list)
-{
-    return run_list->next != NULL;
-}